package com.cskaoyan.service;

import com.cskaoyan.bean.baseresultVO.BaseData;
import com.cskaoyan.bean.baseresultVO.BaseParam;
import com.cskaoyan.bean.wxfootprint.FootprintGoodsVo;
import com.cskaoyan.mapper.FootPrintMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @User: Yr
 * @Date: 2021/12/4
 * @Description: wx小程序 足迹模块 service层实现类
 */

@Service
public class FootPrintServiceImpl implements FootPrintService {



    @Autowired
    FootPrintMapper footPrintMapper;

    @Override
    public BaseData list(BaseParam baseParam,Integer userId) {

        //开启分页
        PageHelper.startPage(baseParam.getPage(),baseParam.getLimit());
        //查询数据 (按时间降序)
        List<FootprintGoodsVo> goodsListInFootprint = footPrintMapper.selectGoodsListInFootprint(userId);
        PageInfo pageInfo = new PageInfo(goodsListInFootprint);

        BaseData data = new BaseData(pageInfo.getPageNum(),baseParam.getLimit(), (int) pageInfo.getTotal(),
                pageInfo.getPages(),goodsListInFootprint);
        return data;
    }
}
